#include "GatewayLoginCmd.h"

GatewayLoginCmd::GatewayLoginCmd(QObject *parent) :
    BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
}

Package GatewayLoginCmd::toPackage()
{
    Package package;
    QByteArray body;
    quint16 strLength;

    strLength = m_loginTime.size();
    body.append(DataTypeConver::intToByteArray(strLength,2));
    body.append(m_loginTime);

    strLength = m_mac.length();
    body.append(DataTypeConver::intToByteArray(strLength,2));
    body.append(m_mac);

  //  body = encrypt(body,KeyType::AES);

    package.setId(m_cmdId);
    package.setFunction(FunctionCode);
    package.setBody(body);

    return package;
}

void GatewayLoginCmd::unPackage(Package package)
{
    m_cmdId = package.id();
}
QByteArray GatewayLoginCmd::loginTime() const
{
    return m_loginTime;
}

void GatewayLoginCmd::setLoginTime(const QByteArray &loginTime)
{
    m_loginTime = loginTime;
}
QString GatewayLoginCmd::mac() const
{
    return m_mac;
}

void GatewayLoginCmd::setMac(const QString &mac)
{
    m_mac = mac;
}


